PageSpinner AppleScript Documentation
Introduction
PageSpinner 2 can be scripted with AppleScript. This means that you can access and control many parts of the inner workings of PageSpinner using commands written in AppleScript. AppleScript is a script language for MacOS that is included in the latest versions of the System software. With PageSpinner's AppleScript support it will be possible to take a script-driven approach to creating, maintaining and updating a site.Even if you don't know how to write AppleScript you will still be able to benefit of PageSpinner's support for scripting, since it enables you to use existing scripts in the AppleScript Menu, in PageSpinner Extensions and in the included database publishing and scripting kits.
Limitations of PageSpinner's AppleScript support:
- PageSpinner is not recordable.
- PageSpinner is not fully scriptable.
- Some script commands requires that PageSpinner is the frontmost application, so to avoid problems you are recommended to always activate PageSpinner before sending a series of commands.
The Getting started with AppleScript page contains links to resources on the web where additional information about AppleScript can be found.
Please note that the current implementation of AppleScript in PageSpinner may be subject to minor changes.
The sample scripts have been tested successfully on different machines and configurations with systems version 7.5.3, 7.5.5 and 7.6, but may need to be modified to work on other systems.Note that the scripts are provided "AS IS", and that Optima System doesn't have resources to give any help or support with AppleScript, but we are of course interested in bug reports and suggestions for improvements or new scripts.
AppleScript Dictionary
See the PageSpinner AppleScript Dictionary for information regarding PageSpinner's AppleScript syntax. In addition PageSpinner supports all the required Apple Events, such as Open and Print.
Database Publishing Kit
By using PageSpinner and AppleScript you can now publish contents of databases on the web. To accomplish this the following items are used:
- An AppleScript created and edited in Script Editor
- A database created and maintained with a database application
- Two template files created and edited in PageSpinner
The script retrieves data from the database, inserts the data into templates created in PageSpinner and creates an index with links to all records.
Read the description on how to do this in PageSpinner Database Publishing.
FAQ-Spinner
FAQ-Spinner is another database kit that shows how a FAQ (list of frequently asked questions) can be maintained as well as edited in a FileMaker Pro database and published on the web with PageSpinner. Registered users are free to use and modify the sample database and templates to publish their FAQs or lists of information with a similar structure. FAQ-Spinner requires FileMaker Pro from Claris.
TextSpinner
TextSpinner is a scripting kit consisting of an AppleScript and ready-made PageSpinner templates that enables you to create a site from plain text files in specific folder.The result from running the script is a complete collection of HTML pages with:
- a frame with table of contents linking to all pages inside another frame,
- pages containing a column with the table of contents or
- classic HTML pages with links to the next and the previous page.
And yes, if you want to give your viewers many options, the script can be set to generate all three versions of the site at the same time!
MailSpinner
MailSpinner is a scripting kit consisting of an AppleScript and PageSpinner templates that show how all email in an Eudora Mailbox can published on the web using PageSpinner. The MailSpinner kit can be useful if you run a small mailing list and you need to publish a digest of mails on the web.
AppleScript Menu
There are several sample AppleScripts included with PageSpinner, most of these are available in PageSpinner's AppleScript Menu. These AppleScripts automate tasks and brings new functions to PageSpinner.
You are able to create new scripts and add these to the menu, just place the compiled script in PageSpinner's Scripts folder. The script folder is located in the same folder as the application. The scripts in the AppleScript menu can also be used to control or extract data from other applications such as Netscape Navigator or the Finder.
Note that the scripts need to be saved as compiled scripts if they are to be run from the AppleScript Menu. Compiled scripts are also slightly faster to execute. Running scripts from PageSpinner's AppleScript menu or OSA Menu also give slightly better performance than running it from another application such as Script Editor. OSA Menu is an extension that adds a script menu in all open applications.
Press the Alt key when selecting a script in the menu to view or edit the script in Script Editor. It is recommended to view the description in this way before running a script for the first time, especially if you have important files open, since some scripts modify the contents in the frontmost document. In most cases it is not possible to undo changes done by a script.
If you don't find a script to be useful, you can remove it from folder "PageSpinner Scripts" to get a shorter Script menu (and slightly faster startup of the application).
The following section contains short descriptions of some of the scripts that are included with PageSpinner.
Backup
Saves the frontmost document if it is modified and then makes a backup copy of the file in the currently selected Backup folder. Requires a scriptable Finder, included in System 7.5 or later.Backup Open...
Opens the last backup of the frontmost document if a copy has been saved in the current Backup folder. Requires a scriptable Finder, included in System 7.5 or later.Backup Root Folder...
Backups the selected root folder (and all files and folders within it), or lets the user select a new root folder. Requires a scriptable Finder, included in System 7.5 or later.Backup Preferences...
Select the backup folder or show the backup folder in Finder. Requires a scriptable Finder, included in System 7.5 or later.
Save All Windows
Saves the open documents to disk.
Save All Windows to Web Server
Saves the open documents to the Web Server. The script doesn't handle the Notebook very well, so close the Notebook before using this script.
Save and Copy to Folder
Saves the frontmost document (if it is modified) and then makes a copy of the file to the folder specified in the script. If you are having a web server folder on your Mac, this script can copy the file to the public folder that contains the web pages. Requires a scriptable Finder, included in System 7.5 or later.NOTE: If there is a file with the same name in the target folder, it will be deleted automatically.
Save Selection as Include...
Saves the selected text of the frontmost window as an include file in the Include Folder inside the selected folder.NOTE: If there is a file with the same name in the Include folder, it will be deleted automatically.
Send to Back
Sends the frontmost document's window to the back, behind all other windows. Can be used to cycle through all open documents.
Convert Mailed Form
Converts text from forms in an HTML page that has been received as email; can be useful to convert those hard to open and read files saved by an email application.The script offer the user to select from where to get the text of the form:
The script then converts the text from the selected source and display the result in a new window. The text should be a form that has been emailed from an HTML page. The script has only been tested with forms sent by Navigator 3.0 and received by Eudora 3.0.
- copy selected text, or entire document if no text is selected in the front document, or the clipboard if no window is open,
- read the contents of a single file
- read contents of all files in a folder
Find and Replace in Folder...
This script shows how do search and replace in all text files located in the same folder. Uses the Finder to get contents of a folder.WARNING! Don't run this script on folders containing important data! Always keep a backup of important files.
Paste Extensions List
Inserts a list of the system's installed Extensions and Control Panels. Could be useful when submitting a bug report.
Paste Links to Folder...
Inserts a list of links to all files in a folder. You will need to supply a path to the files, if the frontmost document isn't in the folder you select. If you select Images in the dialog, the actual images will be inserted and not just a link, making it possible to preview all images in a folder.
Paste Links to Sub Folders...
Inserts a list of links to files of a specific type in a folder and all sub folders. You will need to supply a path to the files, if the frontmost document isn't in the folder you select. If you select Images in the dialog, the actual images will be inserted and not just a link, making it possible to preview all images in a folder.Note that this script may take a very long time to run if there are many files or folders inside the selected folder.
Paste Text File...
Paste a text file into the frontmost window, then displays a Convert Text to HTML Dialog. Finally the script asks if you want to change all tabs in the document into non breaking spaces. The conversions question this can be removed or changed by editing the script.
Show File in Finder
Display the frontmost document's window in Finder. This script requires a scriptable Finder, included in System 7.5 or later.
Show Root Folder in Finder
Displays the contents of the Root folder in a window in Finder. This script requires a scriptable Finder, included in System 7.5 or later. The root folder can be specified in File : Preferences : General or in a script. The path to this folder can be accessed via AppleScript, and could be used to save or open files in. This folder should be set to be the root folder of your web contents. The root folder is used by e.g., the Backup scripts.
Update Include Files in Folder...
Updates all PageSpinner files in a folder that contains an INCLUDE FILE or INCLUDE NB comments (or optionally all files), by opening, saving, and closing them.
View Current Settings
Displays some info about the current settings.
View PageSpinner Dictionary
Displays PageSpinner's AppleScript Dictionary. You may need to change the text "Script Editor" in the script if you are using a localised system.
Demo Scripts
There are additional sample scripts included with PageSpinner in the Goodies folder. Most of these scripts are not as useful as the ones in the AppleScript menu, instead they may be interesting to examine if you want to start programming with AppleScript.
The following section contains short descriptions of some of the demo scripts that are included with PageSpinner.
Demo Web Server Prefs
By using the View PageSpinner Dictionary script in the AppleMenu you can see there are several properties that belong to the PageSpinner application. These can all be set using AppleScript. An example of how to use this can be found in the Demo Web Server Prefs script.The script uses the AppleScript word set to set the values of the PageSpinner properties web server path and web server password in a script:
set web server path to "ftp://user@server/public_html/"
set web server password to "abc"Note that the password will be visible in the script. It is possible to modify the script so that it will display a dialog that asks for the password.
This script can be useful if you have several differents servers or directories you need to switch between; create a different copy for each of the paths used and place the scripts in either the AppleScript menu, OSA menu or in the Apple menu, where you can access them easily.
Demo HTML Tag Replace
This demo script replaces all occurrences of tag pair in the frontmost document. All<B...</B>
tags in the document will be replaced by<STRONG>...</STRONG>
Zoom Window
Zooms the frontmost document's window.